Post

Replies

Boosts

Views

Activity

Reply to SwiftUI bottom-first List (inverted)
I think this is more complicated than just using reversed data. In chat you want to keep offset from the bottom. So when user opens a chat the last (the most recent one) message should be visible, basically bottom content offset is 0. Then, when the chat loads more history, it should keep the current bottom offset. Unfortunately, SwiftUI implementation inserts items from the top and keeps top offset, as it was already mentioned. Also, there is no direct control of scrollview offset in SwiftUI. You could try to use ScrollViewReader for initial loading but not for future history loads because the API is very limited. Flipping the list and then all the items inside back seems like the most suitable solution but it opens a lot of issues (navbar jumping, pull to refresh, scroll indicator direction) and adds extra complexity for the code. Described chat use case seems quite common, I'd vote for an extra special modifier as well.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21